Using Images as Links

Similar to hyperlink text, you can also create hyperlink images. You need to first create an anchor tag (<a>) to create a hyperlink image and give the reference of an HTML page through the href attribute of the <a> tag. Inside the <a> tag, create an <img> tag and give the reference of an image file through the src attribute of the <img> tag. When you click the image, the referenced page opens in the browser.

Let’s do the following steps to use images as links:


<!DOCTYPE html>
<html>
<head>
    <title> Image </title>
</head>
<body>
    <center>
    <h1>Bothe the Image and Text can be a Link</h1>
    <a href=”Page1.html”>
    <img src=”image.gif” alt=”Happy new Year 2018” border=”7” />
    </a>
    </center>
</body>
</html>

Save the document with the name of ImageLink.html and open on browser.

Creating Linked Page


<!DOCTYPE html>
<html>
<head>
    <title>Page </title>
</head>
    <h2> Hey, I am linked to the Next page….</h2>
    <img src=”image.jpg” alt=”My Image” /> 
<body>
</html>

Save the document with the name of Page1.html and open on browser.